<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>帮助中心管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				rules:{
					title:{required:true,minlength:4,maxlength:6,isChinese:true}
				},
				messages:{
					title:{required:'请输入标题',minlength:'请输入4-6个汉字',maxlength:'请输入4-6个汉字'}
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			// 判断中文字符 
		    jQuery.validator.addMethod("isChinese", function(value, element) {       
		         return this.optional(element) || /^[\u0391-\uFFE5]+$/.test(value);       
		    }, "请输入4-6个汉字'"); 
		});
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/sys/help/">帮助中心列表</a></li>
		<li class="active"><a href="${ctx}/sys/help/form?id=${help.id}">帮助中心<shiro:hasPermission name="sys:help:edit">${not empty help.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="sys:help:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="help" action="${ctx}/sys/help/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<div style="display:none;">
			<sys:message content="${message}"/>
		</div>	
		<div class="control-group">
			<label class="control-label">标题：</label>
			<div class="controls">
				<form:input path="title" htmlEscape="false" maxlength="50" class="input-xlarge"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">所属栏目：</label>
			<div class="controls">
				<form:select path="classesType" class="input-medium" disabled="true">
					<form:options items="${fns:getDictList('help_type')}" htmlEscape="false" itemValue="value" itemLabel="label"/>
			    </form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">内容：</label>
			<div class="controls">
					<form:textarea path="content" id="content" htmlEscape="false" rows="4" class="input-xxlarge "/>
				</div>
				<script type="text/javascript" >
	                // Replace the <textarea id="editor1"> with a CKEditor
	                // instance, using default configuration.
	                var path;
	                CKEDITOR.replace( 'content' ,{
	                	filebrowserImageUploadUrl : "${ctx}/sys/file/uploadImage"
	                });
	            </script>
			</div>
		<div class="form-actions">
			<shiro:hasPermission name="sys:help:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="修 改"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>